package com.zzyy.study.config;

import com.zzyy.study.service.ChatAssistant;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.chat.StreamingChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import java.time.Duration;


/**
 * @auther zzyy
 * @create 2025-02-21 22:42
 */
@Configuration(proxyBeanMethods = false)
public class ChatLanguageModelConfig
{
    @Bean
    public StreamingChatLanguageModel streamingChatLanguageModel(){
        return OpenAiStreamingChatModel.builder()
                .apiKey(System.getenv("LANGCHAIN4J_KEY"))
                //.modelName("qwen-vl-max")
                .modelName("qwen-turbo-0624")
                .timeout(Duration.ofSeconds(60))
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }

    /*@Bean
    @Primary
    public StreamingChatLanguageModel streamingChatLanguageModelWithDeepSeek(){
        return OpenAiStreamingChatModel.builder()
                .apiKey("sk-d8c3724e7a4b4d18932852dae9d90c69")
                .modelName("deepseek-chat")
                .baseUrl("https://api.deepseek.com/v1")
                .build();
    }*/

    @Bean
    public ChatAssistant chatAssistant(StreamingChatLanguageModel streamingChatLanguageModel)
    {
        return AiServices.create(ChatAssistant.class, streamingChatLanguageModel);
    }

}


